package com.itheima.dubbo.service;

import com.itheima.dubbo.User;
import org.apache.dubbo.config.annotation.DubboService;
import org.apache.dubbo.config.annotation.Method;
import org.apache.dubbo.rpc.RpcContext;

/**
 * @Description: 幂等性操作
 * @Version: V1.0
 */
//@DubboService(timeout = 3000)  //超时时间，默认是一秒
//@DubboService(methods = {
//        @Method(name = "hello", timeout = 9000)
//})//优先级最高
//    @DubboService(version = "1.0.1")
//    @DubboService(loadbalance = "roundrobin")
    @DubboService
public class UserServiceImpl implements UserInterface {

    @Override
    public String hello(String username) {
        System.out.println("UserServiceImpl......");
        String itcast = RpcContext.getContext().getAttachment("itcast");
        System.out.println(itcast);
        try {
            Thread.sleep(2000L);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        return "Hello Dubbo username: " + username;

    }

    @Override
    public User findUser(User userVo) {
        User user = new User();
        user.setName(userVo.getName());
        return user;
    }
}